class RecentCounter {
  queue: number[]
  constructor() {
    this.queue = []
  }

  ping(t: number): number {
    this.queue.push(t)
    // 将不在范围内的ping移除
    while (this.queue[0] < t - 3000) {
      this.queue.shift()
    }
    return this.queue.length
  }
}